package com.apes.fn.scm.retailOrder.service.expense;

import com.alibaba.fastjson.JSONObject;
import com.apes.fn.business.fixedLoss.modle.LossQuotation;
import com.apes.fn.business.fixedLoss.repository.LossQuotationRepository;
import com.apes.fn.scm.retailOrder.model.RetailOrder;
import com.apes.framework.api.SpringManager;

/**
 * 同公司委托定损费用
 * @Author wuq
 * @Date 2021-10-9
 */
public class InsuranceDiscount extends AbstractRetailOrderFnExpense {

    private RetailOrder retailOrder;

    public InsuranceDiscount(RetailOrder retailOrder){
        super(retailOrder.getAmtTotal(), retailOrder.getSource(), retailOrder.getSourceBusinessType(),
                retailOrder.getId(), retailOrder.getClass().getSimpleName(),
                retailOrder.getCustomerExpand().getCarLicense(), retailOrder.getCaseType());
        this.retailOrder = retailOrder;
    }


    @Override
    public void create(JSONObject condition) {

        // 获取基地分红比例参数
        LossQuotation lossQuotation = SpringManager.getBean(LossQuotationRepository.class).findOne(retailOrder.getSource());
        double ratio = lossQuotation.getDividendBase();
        createLossQuotationExpense(ratio);
    }

    @Override
    public void createPlatformExpense(double expense) {

    }

    @Override
    public void createInfoExpense(double expense) {

    }

    @Override
    public void createLossQuotationExpense(double expense) {
        String infoCode = ExpenseEnum.insuranceDiscountExpense.getCode();

        createExpense(retailOrder.getCompany(), retailOrder.getCompany(), super.getAmount() * expense, infoCode,
                retailOrder.getServiceDept(), retailOrder.getDept(), "同公司委托定损");
    }
}
